import 'package:k3cloud_api/params/request_param.dart';
import 'package:uuid/uuid.dart';

/// it is used to build parameters to request the login interface.
class LoginParam extends RequestParam {
  @override
  String getRequestPath() {
    return "AuthService.ValidateUser";
  }

  @override
  Map<String, dynamic> toJson() => {
    "format": format,
    "useragent": useragent,
    "rid": rid,
    "parameters": parameters,
    "timestamp": timestamp,
    "v": v,
  };

  int format = 1;
  String useragent = "ApiClient";
  String rid = const Uuid().v4();
  List<String> parameters = [];
  String timestamp = DateTime.now().millisecondsSinceEpoch.toString();
  String v = "1.0";

  static _Builder builder() {
    return _Builder();
  }
}

class _Builder {
  final LoginParam _param = LoginParam();
  String _acctID = "";
  String _username = "";
  String _password = "";
  int _lcid = 2052;

  LoginParam build() {
    _param.parameters = [_acctID, _username, _password, _lcid.toString()];
    return _param;
  }
  
  _Builder acctID(String acctID) {
    _acctID = acctID;
    return this;
  }

  _Builder username(String username) {
    _username = username;
    return this;
  }

  _Builder password(String password) {
    _password = password;
    return this;
  }

  _Builder lcid(int lcid) {
    _lcid = lcid;
    return this;
  }
}